package io.kiki.stack.netty.config.switches;

import io.kiki.stack.netty.config.Configs;

import java.util.BitSet;

/**
 * Global switches used in client or server
 * <p>
 * NOTICE:<br>
 * 1. system settings will take effect in all  client or server instances in one process<br>
 * 2. user settings will only take effect in the current instance of  client or server.
 * <p/>
 */
@Deprecated
public class GlobalSwitch implements Switch {


    private final BitSet userSettings = new BitSet();

    /**
     * Init with system default value
     * if settings exist by system property then use system property at first;
     * if no settings exist by system property then use default value in {@link Configs}
     * All these settings can be overwrite by user api settings.
     */
    public GlobalSwitch() {

    }

    // ~~~ public methods
    @Override
    public void turnOn(int index) {
        this.userSettings.set(index);
    }

    @Override
    public void turnOff(int index) {
        this.userSettings.clear(index);
    }

    @Override
    public boolean isOn(int index) {
        return this.userSettings.get(index);
    }
}